
package ro.imc.rest.client.callbacks;

import java.util.List;

import ro.imc.rest.client.display.util.DialogForm;
import ro.imc.rest.client.display.util.MessageConstants;
import ro.imc.rest.shared.dto.LearningObject;

import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.TreeItem;

public class CatalogCallback extends AbstractCallBack {

	TreeItem treeItem;

	public enum EventType {
		SELECT_EVENT, STATE_CHANGE_EVENT
	};
	protected EventType eventType;

	public EventType getEventType() {

		return eventType;
	}

	public void setEventType(EventType eventType) {

		this.eventType = eventType;
	}

	public TreeItem getTreeItem() {

		return treeItem;
	}

	public void setTreeItem(TreeItem treeItem) {

		this.treeItem = treeItem;
	}

	@Override
	protected void processResponse(String response) {
		JSONValue jsonValue = JSONParser.parseLenient(response);
		JSONObject jobj = jsonValue.isObject();
		LearningObject learningObject = new LearningObject();
		learningObject.setId(jobj.get("id").isString().stringValue());
		learningObject.setName(jobj.get("name").isString().stringValue());
		learningObject.setNickName(jobj.get("nickName").isString().stringValue());
		learningObject.setLastName(jobj.get("lastName").isString().stringValue());
		learningObject.setPhone(jobj.get("phone").isString().stringValue());
		learningObject.setTitle(jobj.get("title").isString().stringValue());
	}

}
